#ifndef TABLEFORM_H
#define TABLEFORM_H

#include <QDialog>

namespace Ui {
class TableForm;
}

class HeaderView;
class QSqlRelationalTableModel;
class QModelIndex;

class TableForm : public QDialog
{
    Q_OBJECT
    
public:
    explicit TableForm(QWidget *parent = 0);
    ~TableForm();

    void setTable(const QString& table);

private slots:
    void itemSelected(const QModelIndex& current, const QModelIndex& previous);
    void add();
    void edit();
    void remove();
    void activated(const QModelIndex &index);
    void addItem();
    void editItem(const QModelIndex &index);
    void addDepartment();
    void editDepartment(const QModelIndex &index);
    void addOperator();
    void editOperator(const QModelIndex &index);
    void addStore();
    void editStore(const QModelIndex &index);
    void addOrganization();
    void editOrganization(const QModelIndex &index);

    
    void on_filter_lineEdit_textChanged(const QString &arg1);

private:
    void updateActions();
    void loadCompleter();

    Ui::TableForm *ui;

    HeaderView* headerView;
    QSqlRelationalTableModel* model;

    QAction* addAction;
    QAction* deleteAction;
    QAction* editAction;
};

#endif // TABLEFORM_H
